﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>用户</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <script src="../Static/jquery-1.6.2.min.js" type="text/javascript"></script>
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
    <script src="../Static/boot.js" type="text/javascript"></script>
    <link href="../Static/demo.css" rel="stylesheet" />
    <link href="../Static/miniui/themes/blue/skin.css" rel="stylesheet" />

    <style type="text/css">
        html, body {
            margin: 0;
            padding: 0;
            border: 0;
            width: 100%;
            height: 100%;
            overflow: hidden;
        }
    </style>
</head>
<body>
    <div class="mini-toolbar" style="padding-bottom: 2px; padding-left: 1px; margin: 2px">
        <span>帐号/姓名：</span>
        <input type="text" id="txt_UserAccount" class="mini-textbox" style="width: 100px" />
        <a class="mini-button" onclick="searchUser()" iconcls="icon-search" plain="true">查询</a>
        <span class="separator"></span>
        <a class="mini-button" onclick="clearWhere()" iconcls="icon-remove" plain="true">清空条件</a>
        <span class="separator"></span>
        <a class="mini-button" iconcls="icon-reload" onclick="reloadData()" plain="true">刷新</a>
    </div>
    <div class="mini-fit" style="padding: 0px 0px 0px 0px;">

        <div id="dv_UserList" class="mini-datagrid" style="width: 100%; height: 100%;" url="../Ajax/AjaxService.aspx?method=GetUser" ondrawcell="onDrawCell"
             idfield="ID" allowresize="true" sizelist="[10,15,20,50,100,200,300,500]"
             pagesize="20">
            <div property="columns">
                <div type="indexcolumn" width="10" allowsort="true">
                    序号
                </div>
                <div field="username" width="150" headeralign="center" allowsort="true">
                    账号
                </div>
                <div field="realname" width="150" headeralign="center" allowsort="true">
                    姓名
                </div>
                <div field="View" headeralign="center" align="center">
                    点击查看可查看人员
                </div>
                <div field="Comment" headeralign="center" align="center">
                    点击查看可评论人员
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        mini.parse();
        var grid = mini.get("dv_UserList");
        //grid.load();
        //默认对"UserID"字段，进行降级排序
        grid.sortBy("username", "Asc");
        /**查询******************************************************************************/
        function searchUser() {
            var userAccount = mini.get("txt_UserAccount").getValue();
            grid.load({
                userAccount: userAccount
            });
        }
        function onDrawCell(e) {
            var column = e.column,
                field = e.field,
                value = e.value,
                node = e.record;
            if (field == "View") {
                e.cellHtml = "<a href=\"javascript:void(0);\" onclick=\"ShowUserPermission('" + node.username + "',1)\">点击查看可查看人员</a>";
            }
            else if (field == "Comment") {
                e.cellHtml = "<a href=\"javascript:void(0);\" onclick=\"ShowUserPermission('" + node.username + "',2)\">点击查看可评论人员</a>";
            }
        }
        function ShowUserPermission(userAccount, type) {

            mini.open({
                url: "/AdminMana/Page/UserPermissionMapping.html",
                title: type == 1 ? "可查看用户" : "可评论用户",
                width: 900,
                height: 550,
                onload: function() {
                    var iframe = this.getIFrameEl();
                    var data = { username: userAccount, type: type };
                    iframe.contentWindow.SetData(data);
                },
                ondestroy: function(action) {
                    //grid.reload();
                }
            });
        }

        //-----------------------------清空条件-------------------------
        function clearWhere() {
            mini.get("txt_UserAccount").setValue("");
        }

        function reloadData() {
            grid.sortBy("username", "desc");
            clearWhere();
            grid.load();
        }


        /**在页面按下回车是激发搜索事件******************************************************/
        $("#txt_UserAccount").bind("keydown", function (e) {
            if (e.keyCode == 13) {
                searchUser();
            }
        });

    </script>
</body>
</html>
